package com.link.wseller.mapper;

import com.link.wseller.domain.OrderDetail;
import org.apache.ibatis.jdbc.SQL;

public class OrderDetailSqlProvider {

    public String insertSelective(OrderDetail record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("order_detail");
        
        if (record.getDetailId() != null) {
            sql.VALUES("detail_id", "#{detailId,jdbcType=VARCHAR}");
        }
        
        if (record.getOrderId() != null) {
            sql.VALUES("order_id", "#{orderId,jdbcType=VARCHAR}");
        }
        
        if (record.getProductId() != null) {
            sql.VALUES("product_id", "#{productId,jdbcType=VARCHAR}");
        }
        
        if (record.getProductName() != null) {
            sql.VALUES("product_name", "#{productName,jdbcType=VARCHAR}");
        }
        
        if (record.getProductPrice() != null) {
            sql.VALUES("product_price", "#{productPrice,jdbcType=DECIMAL}");
        }
        
        if (record.getProductQuantity() != null) {
            sql.VALUES("product_quantity", "#{productQuantity,jdbcType=INTEGER}");
        }
        
        if (record.getProductIcon() != null) {
            sql.VALUES("product_icon", "#{productIcon,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(OrderDetail record) {
        SQL sql = new SQL();
        sql.UPDATE("order_detail");
        
        if (record.getOrderId() != null) {
            sql.SET("order_id = #{orderId,jdbcType=VARCHAR}");
        }
        
        if (record.getProductId() != null) {
            sql.SET("product_id = #{productId,jdbcType=VARCHAR}");
        }
        
        if (record.getProductName() != null) {
            sql.SET("product_name = #{productName,jdbcType=VARCHAR}");
        }
        
        if (record.getProductPrice() != null) {
            sql.SET("product_price = #{productPrice,jdbcType=DECIMAL}");
        }
        
        if (record.getProductQuantity() != null) {
            sql.SET("product_quantity = #{productQuantity,jdbcType=INTEGER}");
        }
        
        if (record.getProductIcon() != null) {
            sql.SET("product_icon = #{productIcon,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("detail_id = #{detailId,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}